<?php
    header('Access-Control-Allow-Origin: *');
    header('Content-Type:text/html;charset=utf-8');
    $con = mysqli_connect("127.0.0.1", "root", "root", "mydb");
    $uId = $_GET['uid'];
    $classId = $_GET['classId'];
    $signPwd = $_GET['signPwd'];
    $sql = "SELECT * FROM lesson WHERE l_id = '$classId' AND signPwd = '$signPwd';";
    $res = mysqli_query($con,$sql);
    if(mysqli_fetch_row($res)){
        $nowData = date("Y-m-d");
        $sql1 = "SELECT * FROM lesson_sign WHERE l_id = '$classId' AND s_id = '$uId' AND create_at = '$nowData';";
        $res1 = mysqli_query($con,$sql1);
        if($result = mysqli_fetch_row($res1)){
            echo 'repeat';
        }else{
            $sql2 = "INSERT INTO lesson_sign (l_id,s_id,create_at) VALUES($classId,$uId,'$nowData');";
            $res2 = mysqli_query($con,$sql2);
            echo 'ok';
        }
    }else{
        echo 'fail';
    }
    mysqli_close($con);
?>